﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace VswService_V7.Utility
{
    public static class Formats
    {
        //public static DateTimeFormatInfo GetDateFormat()
        //{
        //	DateTimeFormatInfo dtFormat = new DateTimeFormatInfo();
        //	dtFormat.LongDatePattern = "yyyy/MM/dd HH:mm:ss";
        //	return dtFormat;
        //}

        public static string DataFormat= "yyyy-MM-dd HH:mm:ss";
        public static string GetDateFormat()
        {
            return "yyyy-MM-dd HH:mm:ss";
        }
        public static string GetShortFormat()
        {
            return "yyyy-MM-dd";
        }
        public static string GetTimeFormat()
        {
            return "HH:mm:ss";
        }

        public static string LongFormat = "yyyy-MM-dd HH:mm:ss fff";
        public static string GetLongFormat()
        {
            return "yyyy-MM-dd HH:mm:ss fff";
        }

        public static string DowntimeIdFormat = "yyMMddHHmmss";

        public static string BundleIdFormat = "yyMMddHHmmssfff";

        /// <summary>
        /// Unit conversion
        /// </summary>
        /// <param name="number">Database value</param>
        /// <param name="unit">Data unit divided by</param>
        /// <param name="parse">=0:rounding, >0: not rounding</param>
        /// <returns></returns>
        public static string ConvertUnit(string number,double unit,int parse)
        {
            try
            {
                string newNumber = number.Replace(',', '.');
                double num = double.Parse(newNumber);
                double value = num / unit;
                

                if(parse==0)
                {
                    string[] result = value.ToString().Split('.');
                    if (result.Length > 0)
                        return result[0];
                    else
                        return "0";
                }
                else
                {
                    return value.ToString();
                }
                
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog("ConvertUnit", ex);
                return "0";
            }
        }
    }

    public class VswUnit
    {
        public static double STRIP_THK_L1 = 0.00001;
        public static double STRIP_THK_L2 = 100000.0;

        public static double STRIP_WIDTH_L1 = 0.0001;
        public static double STRIP_WIDTH_L2 = 10000.0;

        public static double Yeild_Strength_L1 = 1.0;
        public static double Yeild_Strength_L2 = 1.0;

        public static double ACC_PR_PRESSURE_L1 = 1.0;
        public static double ACC_PR_PRESSURE_L2 = 1.0;


        public static double PIPE_LENGTH_L1 = 0.001;
        public static double PIPE_LENGTH_L2 = 1000;

        public static double PIPE_OD_L1 = 0.00001;
        public static double PIPE_OD_L2 = 100000.0;

        public static double PIPE_WT_L1 = 0.00001;
        public static double PIPE_WT_L2 = 100000.0;

        public static double INNER_BEAD_HEIGHT_L1 = 0.00001;
        public static double INNER_BEAD_HEIGHT_L2 = 100000.0;

        public static double INNER_BEAD_Depth_L1 = 0.00001;
        public static double INNER_BEAD_Depth_L2 = 100000.0;

        public static double PIEP_OVLITY_L1 = 0.001;
        public static double PIEP_OVLITY_L2 = 1000.0;

        public static double STRAIGHTNESS_L1 = 0.00001;
        public static double STRAIGHTNESS_L2 = 100000.0;

        public static double EM_Cut_SPD_L1 = 1.0;
        public static double EM_Cut_SPD_L2 = 1.0;

        public static double EM_CHIPLOAD_L1 = 0.001;
        public static double EM_CHIPLOAD_L2 = 1000.0;



        public static double Strip_WD_Target_L1 = 0.1;
        public static double Strip_WD_Target_L2 = 10.0;

        public static double HFW_SPC_Gain_L1 = 1.0;
        public static double HFW_SPC_Gain_L2 = 1.0;

        public static double HFW_SPC_Slope_L1 = 0.001;
        public static double HFW_SPC_Slope_L2 = 1000.0;


        public static double Bld_OD_L1 = 0.1;
        public static double Bld_OD_L2 = 10.0;

        public static double Bld_WT_L1 = 0.1;
        public static double Bld_WT_L2 = 10.0;

        public static double Bld_CutArea_L1 = 0.001;
        public static double Bld_CutArea_L2 = 1000.0;

        public static double FLT_Gap_L1 = 1.0;
        public static double FLT_Gap_L2 = 1.0;

        public static double FLT_Time_L1 = 1.0;
        public static double FLT_Time_L2 = 1.0;

        public static double FLT_SPD_L1 = 1.0;
        public static double FLT_SPD_L2 = 1.0;

    }
}
